<?

include_once 'includes/utilities.php';
$link = OpenDB();
$stepNumber = $_POST["stepNumber"];
$codigo = mysql_real_escape_string($_POST["codigo"]);
$clear = PostSQL("delete from template_pap_desc_microscopica where codigo = '" . $codigo . "'");
foreach ($_POST as $key => $value)
{
    if ($value == "on")
    {
        $insert = PostSQL("insert into template_pap_desc_microscopica (codigo, id_desc_microscopica) values
                            ('" . $codigo . "', '" . $key . "')");
    }
    if (substr_count($key, "radio_"))
    {
        $insert = PostSQL("insert into template_pap_desc_microscopica (codigo, id_desc_microscopica) values
                            ('" . $codigo . "', '" . $value . "')");
    }
}
$commit = PostSQL("COMMIT");
CloseDB($link);
header("Location: templatePapDescMicroscopica.php?codigo=" . $codigo . "&step=" . $stepNumber);
?>
